//
//  SignDetailViewController.m
//  掌上海印
//
//  Created by admin on 16/4/16.
//  Copyright © 2016年 handsome. All rights reserved.
//

#import "SignDetailViewController.h"

@interface SignDetailViewController ()<UIAlertViewDelegate>
@property NSTimer *countDownTimer;
@property NSInteger secondsCountDown;
@end

@implementation SignDetailViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"签到";
    _secondsCountDown = 59;//60秒倒计时
    _countDownTimer = [NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(timeFireMethod) userInfo:nil repeats:YES];
    
}

- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
    
}

-(void)timeFireMethod{
    self.second.text = [NSString stringWithFormat:@"%ld",_secondsCountDown];
    _secondsCountDown--;
    if(_secondsCountDown==0){
        [_countDownTimer invalidate];
    }
}


- (IBAction)sign:(id)sender {
    NSDateFormatter *formatter = [[NSDateFormatter alloc]init];
    [formatter setDateFormat:@"HH:mm:ss"];
    NSString *dateTime = [formatter stringFromDate:[NSDate date]];
    NSString *title = [NSString stringWithFormat:@"于 %@ 签到成功",dateTime];
    UIAlertView *alertView = [[UIAlertView alloc]initWithTitle:title message:nil delegate:self cancelButtonTitle:nil otherButtonTitles:@"早上好", nil];
    [alertView show];
}

- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex {
    [self.navigationController popToRootViewControllerAnimated:YES];
}

@end
